from selenium import webdriver
from PIL import Image
import io
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By


def get_tip(tip_png):
    # 使用Pillow处理图片
    image = Image.open(tip_png)

    # 计算验证码图片的位置
    left = 800
    top = 640
    bottom = 680
    right = 1300

    print(left, top, right, bottom)

    # 裁剪验证码图片
    image = image.crop((left, top, right, bottom))

    # 保存验证码图片
    image.save('tip.png')
